/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package glamourbeautyclinic.personel;


import images.GlamourImage;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.DefaultListModel;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.ListModel;
import util.DBConnection;

/**
 *
 * @author anh
 */
public class FrmSpecialist extends javax.swing.JInternalFrame {
    GlamourImage GI = new GlamourImage();
    //DBConnection dc = new DBConnection();
    DBConnection dc;
    DefaultListModel catModel, serModel, specModel;
    /**
     * Creates new form FrmRelApp
     */
    public FrmSpecialist(DBConnection dc, ListModel spec) {
        initComponents();
        this.dc = dc;
        GI.addIconFor(this);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation((screenSize.width - this.getWidth()) / 2, 100);
        
        specModel = new DefaultListModel();
        for (int i = 0;i < spec.getSize();i++){
            specModel.addElement(spec.getElementAt(i));
        }
        lstSpec.setModel(specModel);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblCat = new javax.swing.JLabel();
        lblSer = new javax.swing.JLabel();
        lblSpec = new javax.swing.JLabel();
        jspCat = new javax.swing.JScrollPane();
        lstCat = new javax.swing.JList();
        jspSer = new javax.swing.JScrollPane();
        lstSer = new javax.swing.JList();
        btnForward = new javax.swing.JButton();
        btnBackward = new javax.swing.JButton();
        jspSpec = new javax.swing.JScrollPane();
        lstSpec = new javax.swing.JList();
        pnlButton = new javax.swing.JPanel();
        btnSubmit = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();

        setTitle("<Staff name> 's Specialist");
        setName(""); // NOI18N

        lblCat.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCat.setForeground(new java.awt.Color(0, 51, 255));
        lblCat.setText("Category");

        lblSer.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblSer.setForeground(new java.awt.Color(0, 51, 255));
        lblSer.setText("Available service");

        lblSpec.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblSpec.setForeground(new java.awt.Color(0, 51, 255));
        lblSpec.setText("Employee's specialist");

        lstCat.setForeground(new java.awt.Color(0, 102, 51));
        lstCat.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Hair", "Skin", "Nail" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        lstCat.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jspCat.setViewportView(lstCat);

        lstSer.setForeground(new java.awt.Color(0, 102, 51));
        lstSer.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Haircuts", "Hair dye", "Hairdressing", "Hair Wash", "Deep Conditioning" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jspSer.setViewportView(lstSer);

        btnForward.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnForward.setForeground(new java.awt.Color(0, 51, 51));
        btnForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/001_25.png"))); // NOI18N
        btnForward.setMnemonic('x');
        btnForward.setToolTipText("Save to database");
        btnForward.setBorder(null);
        btnForward.setContentAreaFilled(false);
        btnForward.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnForward.setEnabled(false);
        btnForward.setMargin(new java.awt.Insets(6, 6, 6, 6));
        btnForward.setName(""); // NOI18N
        btnForward.setOpaque(true);
        btnForward.setPreferredSize(new java.awt.Dimension(59, 22));
        btnForward.setRolloverEnabled(false);

        btnBackward.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnBackward.setForeground(new java.awt.Color(0, 51, 51));
        btnBackward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/001_27.png"))); // NOI18N
        btnBackward.setMnemonic('x');
        btnBackward.setToolTipText("Save to database");
        btnBackward.setBorder(null);
        btnBackward.setContentAreaFilled(false);
        btnBackward.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBackward.setEnabled(false);
        btnBackward.setMargin(new java.awt.Insets(6, 6, 6, 6));
        btnBackward.setName(""); // NOI18N
        btnBackward.setOpaque(true);
        btnBackward.setPreferredSize(new java.awt.Dimension(59, 22));
        btnBackward.setRolloverEnabled(false);

        lstSpec.setForeground(new java.awt.Color(0, 102, 51));
        lstSpec.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Haircuts", "Hair dye", "Hairdressing", "Hair Wash", "Deep Conditioning" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jspSpec.setViewportView(lstSpec);

        btnSubmit.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnSubmit.setForeground(new java.awt.Color(0, 51, 51));
        btnSubmit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Submit.png"))); // NOI18N
        btnSubmit.setMnemonic('x');
        btnSubmit.setText("Submit");
        btnSubmit.setToolTipText("Save to database");
        btnSubmit.setBorder(null);
        btnSubmit.setContentAreaFilled(false);
        btnSubmit.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnSubmit.setEnabled(false);
        btnSubmit.setMargin(new java.awt.Insets(6, 6, 6, 6));
        btnSubmit.setName(""); // NOI18N
        btnSubmit.setOpaque(true);
        btnSubmit.setPreferredSize(new java.awt.Dimension(59, 22));
        btnSubmit.setRolloverEnabled(false);
        btnSubmit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSubmitActionPerformed(evt);
            }
        });
        pnlButton.add(btnSubmit);

        btnCancel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        btnCancel.setForeground(new java.awt.Color(0, 51, 51));
        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel.png"))); // NOI18N
        btnCancel.setMnemonic('x');
        btnCancel.setText("Cancel");
        btnCancel.setToolTipText("Save to database");
        btnCancel.setBorder(null);
        btnCancel.setContentAreaFilled(false);
        btnCancel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnCancel.setMargin(new java.awt.Insets(6, 6, 6, 6));
        btnCancel.setName(""); // NOI18N
        btnCancel.setOpaque(true);
        btnCancel.setPreferredSize(new java.awt.Dimension(59, 22));
        btnCancel.setRolloverEnabled(false);
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });
        pnlButton.add(btnCancel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jspCat, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblCat))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jspSer, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnForward, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnBackward, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(lblSer))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblSpec)
                            .addComponent(jspSpec, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(3, 3, 3))
                    .addComponent(pnlButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblSer, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblCat)
                        .addComponent(lblSpec)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jspSer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jspCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jspSpec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(btnForward, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnBackward, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(5, 5, 5)
                .addComponent(pnlButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        displayAllFrame();
        this.dispose();
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitActionPerformed
        // Handle data here:
        displayAllFrame();
        this.dispose();
    }//GEN-LAST:event_btnSubmitActionPerformed

    private void displayAllFrame() {
        JDesktopPane desk = getDesktopPane();
        JInternalFrame[] j = desk.getAllFrames();
        
        for (int i = 0; i < j.length; i++) {
            j[i].setVisible(true);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBackward;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnForward;
    private javax.swing.JButton btnSubmit;
    private javax.swing.JScrollPane jspCat;
    private javax.swing.JScrollPane jspSer;
    private javax.swing.JScrollPane jspSpec;
    private javax.swing.JLabel lblCat;
    private javax.swing.JLabel lblSer;
    private javax.swing.JLabel lblSpec;
    private javax.swing.JList lstCat;
    private javax.swing.JList lstSer;
    private javax.swing.JList lstSpec;
    private javax.swing.JPanel pnlButton;
    // End of variables declaration//GEN-END:variables
}
